<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>


<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>

<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
<title>住院缴费</title>

</head>
<body>
<script src="<c:url value="/js/jquery-migrate-1.1.0.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.jqprint-0.3.js"/>"></script>
<script type="text/javascript">
	$(function(){
		var  shenpi_staffId = $("#tontyiStaffId").html();

		$("#cc_addpayment_save").linkbutton({
			onClick:function(){
				
				$("#cc_pmStaffid").val(shenpi_staffId);
				$("#cc_addpayment_form").form('submit',{
					onSubmit : function() {
						 //返回true提交表单，返回false则阻止表单提交
			             return $(this).form('validate');
					},
					success : function(data) {
						//JSON字符串两边需要添加小括号
						var json = eval("(" + data + ")");
						$.messager.alert("提示", json.reason);
						$("#cc_notpaymenttab").datagrid("reload");
						$(this).form("clear");
					}
				});
			}
		});
		var icid;
		var olddate;
		var newdate;
		$("#cc_querypayment_save").linkbutton({
			onClick:function(){
				icid=$("#cc_query_icid").textbox("getText");
				olddate=$("#cc_query_olddate").datebox("getText");
				newdate=$("#cc_query_newdate").datebox("getText");
				$("#cc_querypayment_form").form('submit',{
					onSubmit : function() {
						 //返回true提交表单，返回false则阻止表单提交
			             return $(this).form('validate');
					},
					success : function(data) {
						$("#show_query_payment_tab").datagrid({
							url:'tocc_querypayment',
							queryParams : {
								icid : icid,
								olddate:olddate,
								newdate:newdate
							}
						});
						$(this).form("clear");
					}
				});
			}
		});
		
		
		$("#cc_addpayment_cancel").linkbutton({
			onClick:function(){
				$("#cc_addpayment_form").form("clear");
			}
		});
		$("#cc_notpayment_ref").linkbutton({
			onClick:function(){
				$("#cc_notpaymenttab").datagrid("reload");
			}
		});
		$("#cc_querypayment_ref").linkbutton({
			onClick:function(){
				$("#show_query_payment_tab").datagrid("reload");
			}
		});
		//cc_deductdetail_ref
		//show_deductdetail_win 
		$("#cc_deductdetail_ref").linkbutton({
			onClick:function(){
				$("#show_deductdetail_tab").datagrid("reload");
			}
		});
		//cc_query_payment_form
		//cc_querypayment_save
		
		$("#cc_show_querydeductdetail").linkbutton({
			onClick:function(){
				var rows =$("#show_query_payment_tab").datagrid("getSelections");
				if (rows.length == 1) {
					//tocc_querydeductdetail
					var deductid=rows[0].deductid;
					$("#show_deductdetail_win").window("open");
					$("#show_deductdetail_tab").datagrid({
						url:'tocc_querydeductdetail',
						queryParams : {
							deductid : deductid
						}
					});
				} else {
					$.messager.alert("提示", "只能选择一条记录，您目前选择了"
							+ rows.length + "条!");
				}
			}
		});
		$("#cc_querypayment_print").linkbutton({
			onClick:function(){	
				//cc_querypayment_print_show
				var rows=$("#show_query_payment_tab").datagrid("getSelections");
				if(rows.length>0){
					$("#show_print_dd").remove();
					
					$("<table id='show_print_dd' style='border: 1px solid #999; border-collapse:collapse;margin-left:20%;margin-top:20px;text-align:center;'></table>").appendTo($("#cc_querypayment_print_show_form"));
					
					var cc_tab=$("#show_print_dd");
					$("<tr><th style='border: 1px solid #999;'>患者姓名</th><th style='border: 1px solid #999;'>医疗卡号</th><th style='border: 1px solid #999;'>消费金额</th><th style='border: 1px solid #999;'>消费时间</th></tr>").appendTo(cc_tab);
					for(var i=0; i<rows.length;i++){
						$("<tr><td style='border: 1px solid #999;'>"+rows[i].pname+"</td><td style='border: 1px solid #999;'>"+rows[i].icid+"</td><td style='border: 1px solid #999;'>"+rows[i].dmoney+"</td><td style='border: 1px solid #999;'>"+rows[i].dedate+"</td></tr>").appendTo(cc_tab);
					}
					$("#cc_querypayment_print_show").window('open');
				}
				//$.print("#show_query_payment_tab");
			}
		});
		$("#cc_deductdetail_print").linkbutton({
			onClick:function(){
				//show_deductdetail_tab
				//var html=$("#show_deductdetail_tab").html();
				//printdiv(html);
				//$.print("#show_deductdetail_tab");
				var rows=$("#show_deductdetail_tab").datagrid("getRows");
				$("#show_print_dd").remove();
				
				$("<table id='show_print_dd' style='border: 1px solid #999; border-collapse:collapse;margin-left:10%;margin-top:20px;text-align:center;'></table>").appendTo($("#cc_querypayment_print_show_form"));
				
				var cc_tab=$("#show_print_dd");
				$("<tr><th style='border: 1px solid #999;'>患者姓名</th><th style='border: 1px solid #999;'>医疗卡号</th><th style='border: 1px solid #999;'>消费项目</th><th style='border: 1px solid #999;'>消费金额</th><th style='border: 1px solid #999;'>消费时间</th></tr>").appendTo(cc_tab);
				for(var i=0; i<rows.length;i++){
					$("<tr><td style='border: 1px solid #999;'>"+rows[i].pname+"</td><td style='border: 1px solid #999;'>"+rows[i].icid+"</td><td style='border: 1px solid #999;'>"+rows[i].ddname+"</td><td style='border: 1px solid #999;'>"+rows[i].ddmoney+"</td><td style='border: 1px solid #999;'>"+rows[i].dddate+"</td></tr>").appendTo(cc_tab);
				}
				$("#cc_querypayment_print_show").window('open');
			}
		});
		$("#cc_query_payment_save").linkbutton({
			onClick:function(){
				var icid=$("#cc_query_icid1").textbox("getValue");
				//alert(icid);
				$("#cc_queryOnepayment_tab").datagrid({
					url:'tocc_queryByOneCcPrepayment',
					queryParams : {
						icid : icid
					}
				});
			}
		});
		$("#cc_paymentprint_ok").click(function(){
				$("#cc_print_payment").jqprint();
		});
		$("#cc_paymentprint_cancel").linkbutton({
			onClick:function(){
				$("#show_print_dd").remove();
				$("#cc_querypayment_print_show").window('close');
			}
		});
	});
</script>
<%-- <script type="text/javascript"
	src="<c:url value="/js/jquery-1.4.4.min.js"/>"></script> --%>
<div>
	<form id="cc_addpayment_form" action="tocc_addccPayment" method="post">
		<div style="display: none;">
				<input id="cc_pmStaffid" name="pmStaffid">
		</div>
		<table style="width:100%;font-size:12px;background: rgb(236,243,255); padding: 10px; border-radius: 5px;">
			<tr>
				<td width="30%"><input name="picid" class="easyui-textbox" data-options="
					label:'医疗卡号:',
					labelWidth:'90',
					labelAlign:'right',
					required: true,
					width:'100%'			
					"></td>
				<td width="30%"><input name="pmoney" class="easyui-numberbox" data-options="
					min:0,precision:2,
					label:'收取金额:',
					labelWidth:'90',
					labelAlign:'right',
					required: true,
					width:'100%'	
					">
				</td>
				<td width="20%">
					<a id="cc_addpayment_save"  class="easyui-linkbutton" data-options="iconCls:'icon-baocun'">确定</a>
					<a id="cc_addpayment_cancel" style="margin-left:30px" class="easyui-linkbutton" data-options="iconCls:'icon-chexiao'">取消</a>
				</td>
				<td width="20%">
				</td>
			</tr>
		</table>
	</form>
<div id="cc_payment_tab" class="easyui-tabs" style="width:100%; margin-top: 15px;"
				data-options="plain:true,narrow:true">

<div title="消费查询">
	<form id="cc_querypayment_form" action="" method="post">
		<table style="width:100%;font-size:12px;background: rgb(236,243,255); padding: 0px; border-radius: 5px;">
			<tr>
				<td width="30%"><input id="cc_query_icid" name="icid" class="easyui-textbox" data-options="
					label:'医疗卡号:',
					labelWidth:'90',
					labelAlign:'right',
					required: true,
					width:'75%'			
					"></td>
				<td width="30%"><input id="cc_query_olddate" name="olddate" class="easyui-datebox" data-options="
					min:0,precision:2,
					label:'开始日期:',
					labelWidth:'90',
					labelAlign:'right',
					width:'75%'	
					">
				</td>
			</tr>
			<tr>
				<td width="30%"><input id="cc_query_newdate" name="newdate" class="easyui-datebox" data-options="
					label:'结束日期:',
					labelWidth:'90',
					labelAlign:'right',
					width:'75%'			
					"></td>
				<td width="30%" >
					<a id="cc_querypayment_save" style="margin-left:100px"  class="easyui-linkbutton" data-options="iconCls:'icon-baocun'">确定</a>
					<a id="cc_querypayment_cancel" style="margin-left:60px" class="easyui-linkbutton" data-options="iconCls:'icon-chexiao'">取消</a>
				</td>
			</tr>
		</table>
	</form>
		<table style="width:100%; font-size:12px; padding:0px;margin: 0px;height:100%">
			<tr>
				<td width="47%" height="323px">
					<table id="show_query_payment_tab" class="easyui-datagrid"
					data-options="
								fitColumns:true,
								fit:true,
								rownumbers: true,
								toolbar: '#cc_querypayment_btn',
								pagination:true,
								striped:true,
								pageSize: 9,
								pageList:[9,18,36,45],
								border:false 
							">
					<thead>
						<tr>
							<th data-options="field:'deductid',width:'10%',checkbox:true">消费编号</th>
							<th data-options="field:'pname',width:'22%'">病人姓名</th>
							<th data-options="field:'icid',width:'24%'">医疗卡号</th>
							<th data-options="field:'dmoney', width:'21%'">消费总金额</th>
							<th data-options="field:'dedate',width:'31%',
								formatter:function(value){
			                          var date = new Date(value);  
			                          return date.toLocaleDateString();  
			                        }">消费日期</th>
						</tr>
					</thead>
				</table>
			</td>
			<td width="47%" height="323px">
		<!-- 余额不足 -->
				<table id="cc_notpaymenttab" class="easyui-datagrid"
				data-options="
							fitColumns:true,
							fit:true,
							url:'tocc_queryByppmoney',
							toolbar: '#cc_notpayment_btn',
							rownumbers: true,
							pagination:true,
							pageSize: 9,
							pageList:[9,18,36,45],
							border:false 
						">
				<thead>
					<tr>
						<th data-options="field:'deductid',width:'6%',checkbox:true">住院编号</th>
						<th data-options="field:'pname',width:'20%'">病人姓名</th>
						<th data-options="field:'icid',width:'20%'">医疗卡号</th>
						<th data-options="field:'wname',width:'21%'">所住病房</th>
						<th data-options="field:'bname', width:'21%'">床位</th>
						<th data-options="field:'ppmoney',width:'16%'">余额</th>
					</tr>
				</thead>
			</table>
				</td>
			</tr>
		
		</table>
	</div>
<div title="余额查询">
<form id="cc_query_payment_form" action="" method="post">
	
		<table style="width:100%;font-size:12px;background: rgb(236,243,255); padding: 10px; border-radius: 5px;">
			<tr>
				<td width="60%"><input id="cc_query_icid1" class="easyui-textbox" data-options="
					label:'医疗卡号:',
					labelWidth:'90',
					labelAlign:'right',
					required: true,
					width:'75%'			
					"></td>
				
				<td width="40%">
					<a id="cc_query_payment_save"  class="easyui-linkbutton" data-options="iconCls:'icon-baocun'">确定</a>
					<a id="cc_query_payment_cancel" style="margin-left:30px" class="easyui-linkbutton" data-options="iconCls:'icon-chexiao'">取消</a>
				</td>
				<td width="20%">
				</td>
			</tr>
		</table>
	</form>
	<table id="cc_queryOnepayment_tab" class="easyui-datagrid"
				data-options="
							fitColumns:true,
							rownumbers: true,
							striped:true,
							border:false 
						">
				<thead>
					<tr>
						<th data-options="field:'deductid',width:'6%',checkbox:true">住院编号</th>
						<th data-options="field:'pname',width:'20%'">病人姓名</th>
						<th data-options="field:'icid',width:'20%'">医疗卡号</th>
						<th data-options="field:'wname',width:'20%'">所住病房</th>
						<th data-options="field:'bname', width:'20%'">床位</th>
						<th data-options="field:'ppmoney',width:'14%'">余额</th>
					</tr>
				</thead>
			</table>
</div>
	</div>
	<div id="cc_querypayment_btn" width="100%">
			<a id="cc_querypayment_print" class="easyui-linkbutton"
				data-options="iconCls:'icon-print',plain:true">打印选中的记录</a>
				<a id="cc_show_querydeductdetail" class="easyui-linkbutton"
				data-options="iconCls:'icon-help',plain:true">查看详细信息</a><a
				id="cc_querypayment_ref" class="easyui-linkbutton"
				data-options="iconCls:'icon-reload',plain:true">刷新</a>
	</div>
	<div id="cc_notpayment_btn" width="100%">
	<a id="" class="easyui-linkbutton"
				data-options="iconCls:'icon-yu_e',plain:true,disabled:true">预交金不足的患者</a>
			<a id="cc_notpayment_ref" class="easyui-linkbutton"
				data-options="iconCls:'icon-reload',plain:true">刷新</a>
	</div>
	<div id="show_deductdetail_win" class="easyui-window"
			style="padding:0px;line-height: 150%;"
			data-options="
			iconCls:'icon-help',
		     width: 470,
		     height: 320,
		     closed: true,
		      modal:true,
		     title:'消费详情'
			">
		<table id="show_deductdetail_tab" class="easyui-datagrid"
					data-options="
								fitColumns:true,
								fit:true,
								rownumbers: true,
								toolbar: '#cc_deductdetail_btn',
								pagination:true,
								pageSize: 9,
								pageList:[9,18,27,36],
								border:false 
							">
					<thead>
						<tr>
							<th data-options="field:'ddetailid',width:'16%'">消费编号</th>
							<th data-options="field:'pname',width:'14%'">病人姓名</th>
							<th data-options="field:'icid',width:'14%'">医疗卡号</th>
							<th data-options="field:'ddname',width:'20%'">消费项目</th>
							<th data-options="field:'ddmoney', width:'18%'">消费金额</th>
							<th data-options="field:'dddate',width:'20%',
								formatter:function(value){
			                          var date = new Date(value);  
			                          return date.toLocaleDateString();  
			                        }">消费日期</th>
						</tr>
					</thead>
				</table>
			<div id="cc_deductdetail_btn" width="100%">
				<a id="cc_deductdetail_print" class="easyui-linkbutton"
					data-options="iconCls:'icon-print',plain:true">打印当前页的记录</a><a
					id="cc_deductdetail_ref" class="easyui-linkbutton"
					data-options="iconCls:'icon-reload',plain:true">刷新</a>
			</div>
	</div>
	
</div>
<div id="cc_querypayment_print_show" class="easyui-window"
		style="padding: 0px; line-height: 150%;background: rgb(236,243,255);"
		data-options="iconCls:'icon-print',
		     width: 370,
		     height: 330,
		     closed: true,
		      modal:true,
		     title:'中心医院消费清单'
			">
			<div id="cc_print_payment">
			<form id="cc_querypayment_print_show_form">
			
			</form>
			</div>
	<div style="margin-top:10px;margin-left: 31%">
		<a id="cc_paymentprint_ok"  class="easyui-linkbutton" data-options="iconCls:'icon-print'">打印</a>
		<a id="cc_paymentprint_cancel" style="margin-left:30px" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'">取消</a>
	
	</div>
</div>
</body>
</html>